<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->model('hasoffer');
		$this->load->model('common');
		$this->load->helper('date');
		$arr=array();
		$date=new DateTime();
		$arr['api']=-1;
		$arr['offer']=-1;
		$arr['from']=$date->format('Y-m-d');
		$arr['to']=$date->format('Y-m-d');
		$arr['type']=1;
		//print_r($this->input->post());
		if($this->input->post('find')!=NULL||$this->input->post('api')!=NULL)
		{
			$arr['api']=$this->input->post('api');
			$arr['offer']=$this->input->post('offer');
			$arr['from']=$this->input->post('from');
			$arr['to']=$this->input->post('to');
			$arr['type']=$this->input->post('type');
		}
		$rs=json_decode($this->hasoffer->PostReport($arr));
		//print_r(($rs->response->data));
		$data['data']=$rs->response->data->data;
		$rs=json_decode($this->hasoffer->GetOffer($arr));
		//print_r();
		$data['offer']=$rs->response->data;//$rs->response->data;
		//print_r($this->common->Get('api'));
		$rs=$this->hasoffer->GetApi('api');
		$data['api']=$rs;
		$data['old']=json_decode(json_encode($arr));
		
		
		$this->load->view('common/header');
		$this->load->view('report',$data);
		$this->load->view('common/footer');
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */